<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Dart : Libraries : box2d : Body</title>
</head>

<body>

<header></header>

<h1 id="title">class <a name='Body::Body'>Body</a></h1>

<section id="inheritance">

<section class="supertype">
<h2>Supertype:</h2>
<ul><li>Object</li></ul>
</section>

</section>

<section id="summary">

 A rigid body. Bodies are created using World.createBody.
</section>

<section id="fields">
<h2>Fields</h2>
<dl>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::ACTIVE_FLAG'>ACTIVE_FLAG
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::AUTO_SLEEP_FLAG'>AUTO_SLEEP_FLAG
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::AWAKE_FLAG'>AWAKE_FLAG
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::BULLET_FLAG'>BULLET_FLAG
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::FIXED_ROTATION_FLAG'>FIXED_ROTATION_FLAG
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::ISLAND_FLAG'>ISLAND_FLAG
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::TO_I_FLAG'>TO_I_FLAG
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='bool.html#bool::bool'>bool</a></code></code></span>
<span class="field-name"><code><a name='Body::active'>active
</a></code></span>
</dt>
<dd>

 Set the active state of the body. An inactive body is not
 simulated and cannot be collided with or woken up.
 If you pass a flag of true, all fixtures will be added to the
 broad-phase.
 If you pass a flag of false, all fixtures will be removed from
 the broad-phase and all contacts will be destroyed.
 Fixtures and joints are otherwise unaffected. You may continue
 to create/destroy fixtures and joints on inactive bodies.
 Fixtures on an inactive body are implicitly inactive and will
 not participate in collisions, ray-casts, or queries.
 Joints connected to an inactive body are implicitly inactive.
 An inactive body is still owned by a World object and remains
 in the body list.
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::angle'>angle
</a></code></span>
</dt>
<dd>

 Get the angle in radians.
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::angularDamping'>angularDamping
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::angularVelocity'>angularVelocity
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='bool.html#bool::bool'>bool</a></code></code></span>
<span class="field-name"><code><a name='Body::awake'>awake
</a></code></span>
</dt>
<dd>

 The sleep state of the body. A sleeping body has very
 low CPU cost.
</dd>
<dt>
<span class="field-type"><code><code><a href='bool.html#bool::bool'>bool</a></code></code></span>
<span class="field-name"><code><a name='Body::bullet'>bullet
</a></code></span>
</dt>
<dd>
 Is this body treated like a bullet for continuous collision detection? </dd>
<dt>
<span class="field-type"><code><code><a href='ContactEdge.html#ContactEdge::ContactEdge'>ContactEdge</a></code></code></span>
<span class="field-name"><code><a name='Body::contactList'>contactList
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='bool.html#bool::bool'>bool</a></code></code></span>
<span class="field-name"><code><a name='Body::fixedRotation'>fixedRotation
</a></code></span>
</dt>
<dd>

 Set this body to have fixed rotation. This causes the mass
 to be reset.
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::fixtureCount'>fixtureCount
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Fixture.html#Fixture::Fixture'>Fixture</a></code></code></span>
<span class="field-name"><code><a name='Body::fixtureList'>fixtureList
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::flags'>flags
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::inertia'>inertia
</a></code></span>
</dt>
<dd>

 Get the central rotational inertia of the body.

 returns the rotational inertia, usually in kg-m^2.
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::invInertia'>invInertia
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::invMass'>invMass
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::islandIndex'>islandIndex
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='JointEdge.html#JointEdge::JointEdge'>JointEdge</a></code></code></span>
<span class="field-name"><code><a name='Body::jointList'>jointList
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::linearDamping'>linearDamping
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Vector.html#Vector::Vector'>Vector</a></code></code></span>
<span class="field-name"><code><a name='Body::linearVelocity'>linearVelocity
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Vector.html#Vector::Vector'>Vector</a></code></code></span>
<span class="field-name"><code><a name='Body::localCenter'>localCenter
</a></code></span>
</dt>
<dd>

 Get the local position of the center of mass. Do not modify.
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::mass'>mass
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='MassData.html#MassData::MassData'>MassData</a></code></code></span>
<span class="field-name"><code><a name='Body::massData'>massData
</a></code></span>
</dt>
<dd>

 Set the mass properties to override the mass properties of the fixtures.
 Note that this changes the center of mass position.
 Note that creating or destroying fixtures can also alter the mass.
 This function has no effect if the body isn't dynamic.

 data
   the mass properties.
</dd>
<dt>
<span class="field-type"><code><code><a href='Body.html#Body::Body'>Body</a></code></code></span>
<span class="field-name"><code><a name='Body::next'>next
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Vector.html#Vector::Vector'>Vector</a></code></code></span>
<span class="field-name"><code><a name='Body::oldCenter'>oldCenter
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Transform.html#Transform::Transform'>Transform</a></code></code></span>
<span class="field-name"><code><a name='Body::originTransform'>originTransform
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Vector.html#Vector::Vector'>Vector</a></code></code></span>
<span class="field-name"><code><a name='Body::position'>position
</a></code></span>
</dt>
<dd>

 Get the world body origin position. Do not modify.
</dd>
<dt>
<span class="field-type"><code><code><a href='Body.html#Body::Body'>Body</a></code></code></span>
<span class="field-name"><code><a name='Body::prev'>prev
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='num.html#num::num'>num</a></code></code></span>
<span class="field-name"><code><a name='Body::sleepTime'>sleepTime
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='bool.html#bool::bool'>bool</a></code></code></span>
<span class="field-name"><code><a name='Body::sleepingAllowed'>sleepingAllowed
</a></code></span>
</dt>
<dd>

 You can disable sleeping on this body. If you disable sleeping, the
 body will be woken.
</dd>
<dt>
<span class="field-type"><code><code><a href='Sweep.html#Sweep::Sweep'>Sweep</a></code></code></span>
<span class="field-name"><code><a name='Body::sweep'>sweep
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Vector.html#Vector::Vector'>Vector</a></code></code></span>
<span class="field-name"><code><a name='Body::tempCenter'>tempCenter
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='int.html#int::int'>int</a></code></code></span>
<span class="field-name"><code><a name='Body::type'>type
</a></code></span>
</dt>
<dd>

 The type of this body. Either dynamic, static, or kinematic.
</dd>
<dt>
<span class="field-type"><code><code><a href='Object.html#Object::Object'>Object</a></code></code></span>
<span class="field-name"><code><a name='Body::userData'>userData
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='World.html#World::World'>World</a></code></code></span>
<span class="field-name"><code><a name='Body::world'>world
</a></code></span>
</dt>
<dd>
</dd>
<dt>
<span class="field-type"><code><code><a href='Vector.html#Vector::Vector'>Vector</a></code></code></span>
<span class="field-name"><code><a name='Body::worldCenter'>worldCenter
</a></code></span>
</dt>
<dd>

 Get the world position of the center of mass. Do not modify.
</dd>
</dl>
</section>

<section id="constructors">
<h2>Constructors</h2>
<dl>
<dt>
<code><a href='Body.html#Body::Body'>Body</a>(<code><a href='BodyDef.html#BodyDef::BodyDef'>BodyDef</a></code> <a name='Body::::bd'>bd</a>, <code><a href='World.html#World::World'>World</a></code> <a name='Body::::world'>world</a>)</code>
</dt>
<dd>
</dd>
</dl>
</section>

<section id="methods">
<h2>Methods</h2>
<dl>
<dt>
<code>void <a name='Body::advance'>advance</a>(<code><a href='num.html#num::num'>num</a></code> <a name='Body::advance::t'>t</a>)</code></dt>
<dd>
</dd>
<dt>
<code>void <a name='Body::applyAngularImpulse'>applyAngularImpulse</a>(<code><a href='num.html#num::num'>num</a></code> <a name='Body::applyAngularImpulse::impulse'>impulse</a>)</code></dt>
<dd>

 Apply an angular impulse.

 impulse
   the angular impulse in units of kg*m*m/s
</dd>
<dt>
<code>void <a name='Body::applyForce'>applyForce</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::applyForce::force'>force</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::applyForce::point'>point</a>)</code></dt>
<dd>

 Apply a force at a world point. If the force is not
 applied at the center of mass, it will generate a torque and
 affect the angular velocity. This wakes up the body.

 force
   the world force vector, usually in Newtons (N).
 point
   the world position of the point of application.
</dd>
<dt>
<code>void <a name='Body::applyLinearImpulse'>applyLinearImpulse</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::applyLinearImpulse::impulse'>impulse</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::applyLinearImpulse::point'>point</a>)</code></dt>
<dd>

 Apply an impulse at a point. This immediately modifies the velocity.
 It also modifies the angular velocity if the point of application
 is not at the center of mass. This wakes up the body.

 impulse
   the world impulse vector, usually in N-seconds or kg-m/s.
 point
   the world position of the point of application.
</dd>
<dt>
<code>void <a name='Body::applyTorque'>applyTorque</a>(<code><a href='num.html#num::num'>num</a></code> <a name='Body::applyTorque::torque'>torque</a>)</code></dt>
<dd>

 Apply a torque. This affects the angular velocity
 without affecting the linear velocity of the center of mass.
 This wakes up the body.

 torque
   about the z-axis (out of the screen), usually in N-m.
</dd>
<dt>
<code><code><a href='Fixture.html#Fixture::Fixture'>Fixture</a></code> <a name='Body::createFixture'>createFixture</a>(<code><a href='FixtureDef.html#FixtureDef::FixtureDef'>FixtureDef</a></code> <a name='Body::createFixture::def'>def</a>)</code></dt>
<dd>

 Creates a fixture and attach it to this body. Use this function if you need
 to set some fixture parameters, like friction. Otherwise you can create the
 fixture directly from a shape.
 If the density is non-zero, this function automatically updates the mass
 of the body.
 Contacts are not created until the next time step.
</dd>
<dt>
<code><code><a href='Fixture.html#Fixture::Fixture'>Fixture</a></code> <a name='Body::createFixtureFromShape'>createFixtureFromShape</a>(<code><a href='Shape.html#Shape::Shape'>Shape</a></code> <a name='Body::createFixtureFromShape::shape'>shape</a>, [<code><a href='num.html#num::num'>num</a></code> <a name='Body::createFixtureFromShape::density'>density</a> = 0])</code></dt>
<dd>

 Creates a fixture from a shape and attach it to this body.
 This is a convenience function. Use FixtureDef if you need to set
 parameters like friction, restitution, user data, or filtering.
 If the density is non-zero, this function automatically updates the mass
 of the body.
</dd>
<dt>
<code>void <a name='Body::destroyFixture'>destroyFixture</a>(<code><a href='Fixture.html#Fixture::Fixture'>Fixture</a></code> <a name='Body::destroyFixture::fixture'>fixture</a>)</code></dt>
<dd>

 Destroy a fixture. This removes the fixture from the broad-phase and
 destroys all contacts associated with this fixture. This will
 automatically adjust the mass of the body if the body is dynamic and the
 fixture has positive density.
 All fixtures attached to a body are implicitly destroyed when the body is
 destroyed.
</dd>
<dt>
<code><code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromLocalPoint'>getLinearVelocityFromLocalPoint</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromLocalPoint::localPoint'>localPoint</a>)</code></dt>
<dd>

 Get the world velocity of a local point.

 localPoint: point in local coordinates.
 returns the world velocity of a point.
</dd>
<dt>
<code>void <a name='Body::getLinearVelocityFromLocalPointToOut'>getLinearVelocityFromLocalPointToOut</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromLocalPointToOut::localPoint'>localPoint</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromLocalPointToOut::out'>out</a>)</code></dt>
<dd>

 Get the world velocity of a local point and store the result in the given
 out parameter.
</dd>
<dt>
<code><code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromWorldPoint'>getLinearVelocityFromWorldPoint</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromWorldPoint::worldPoint'>worldPoint</a>)</code></dt>
<dd>

 Get the world linear velocity of a world point attached to this body.

 worldPoint: point in world coordinates.
 returns the world velocity of a point.
</dd>
<dt>
<code>void <a name='Body::getLinearVelocityFromWorldPointToOut'>getLinearVelocityFromWorldPointToOut</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromWorldPointToOut::worldPoint'>worldPoint</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLinearVelocityFromWorldPointToOut::out'>out</a>)</code></dt>
<dd>
</dd>
<dt>
<code><code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalPoint'>getLocalPoint</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalPoint::worldPoint'>worldPoint</a>)</code></dt>
<dd>

 Gets a local point relative to the body's origin given a world point.

 worldPoint: point in world coordinates.
 returns the corresponding local point relative to the body's origin.
</dd>
<dt>
<code>void <a name='Body::getLocalPointToOut'>getLocalPointToOut</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalPointToOut::worldPoint'>worldPoint</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalPointToOut::out'>out</a>)</code></dt>
<dd>

 Gets a local point relative to the body's origin given a world point.
 Returns this through the given out parameter.
</dd>
<dt>
<code><code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalVector'>getLocalVector</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalVector::worldVector'>worldVector</a>)</code></dt>
<dd>

 Gets a local vector given a world vector.

 worldVector: vector in world coordinates.
 returns the corresponding local vector.
</dd>
<dt>
<code>void <a name='Body::getLocalVectorToOut'>getLocalVectorToOut</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalVectorToOut::worldVector'>worldVector</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getLocalVectorToOut::out'>out</a>)</code></dt>
<dd>

 Gets a local vector given a world vector and stores the result in the given
 out parameter.
</dd>
<dt>
<code>void <a name='Body::getMassData'>getMassData</a>(<code><a href='MassData.html#MassData::MassData'>MassData</a></code> <a name='Body::getMassData::data'>data</a>)</code></dt>
<dd>

 Get the mass data of the body. The rotational inertia is relative
 to the center of mass. Result is returned through the given out parameter
 data.
</dd>
<dt>
<code><code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldPoint'>getWorldPoint</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldPoint::localPoint'>localPoint</a>)</code></dt>
<dd>

 Get the world coordinates of a point given the local coordinates.

 localPoint
   a point on the body measured relative the the body's origin.
 returns the same point expressed in world coordinates.
</dd>
<dt>
<code>void <a name='Body::getWorldPointToOut'>getWorldPointToOut</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldPointToOut::localPoint'>localPoint</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldPointToOut::out'>out</a>)</code></dt>
<dd>

 Get the world coordinates of a point given the local coordinates to the
 given out parameter.
</dd>
<dt>
<code><code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldVector'>getWorldVector</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldVector::localVector'>localVector</a>)</code></dt>
<dd>

 Get the world coordinates of a vector given the local coordinates.

 localVector: a vector fixed in the body.
 return the same vector expressed in world coordinates.
</dd>
<dt>
<code>void <a name='Body::getWorldVectorToOut'>getWorldVectorToOut</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldVectorToOut::localVector'>localVector</a>, <code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::getWorldVectorToOut::out'>out</a>)</code></dt>
<dd>

 Get the world coordinates of a vector given the local coordinates to the
 given out paramater.
</dd>
<dt>
<code>void <a name='Body::resetMassData'>resetMassData</a>()</code></dt>
<dd>

 This resets the mass properties to the sum of the mass properties of the
 fixtures.
 This normally does not need to be called unless you called setMassData to
 override the mass and you later want to reset the mass.
</dd>
<dt>
<code>void <a name='Body::setTransform'>setTransform</a>(<code><a href='Vector.html#Vector::Vector'>Vector</a></code> <a name='Body::setTransform::argPosition'>argPosition</a>, <code><a href='num.html#num::num'>num</a></code> <a name='Body::setTransform::argAngle'>argAngle</a>)</code></dt>
<dd>

 Set the position of the body's origin and rotation.
 This breaks any contacts and wakes the other bodies.
 Manipulating a body's transform may cause non-physical behavior.
</dd>
<dt>
<code><code><a href='bool.html#bool::bool'>bool</a></code> <a name='Body::shouldCollide'>shouldCollide</a>(<code><a href='Body.html#Body::Body'>Body</a></code> <a name='Body::shouldCollide::other'>other</a>)</code></dt>
<dd>

 This is used to prevent connected bodies from colliding.
 It may lie, depending on the collideConnected flag.
</dd>
<dt>
<code>void <a name='Body::synchronizeFixtures'>synchronizeFixtures</a>()</code></dt>
<dd>
</dd>
<dt>
<code>void <a name='Body::synchronizeTransform'>synchronizeTransform</a>()</code></dt>
<dd>
</dd>
</dl>
</section>

<footer></footer>

</body></html>
